// 修复 Enter 的时候,还保留上次的  block 类型的 bug

export const onKeyDown = (event, data, state) => {
  if (event.which !== 13)return;

  if (
    event.shiftKey
  ) {
    return;
  }

  if (state.anchorInline && state.anchorInline.type === 'link') {
    return state
      .transform()
      .unwrapInline('link')
      .splitBlock()
      .setBlock('paragraph')
      .apply()
  }

  return state
    .transform()
    .splitBlock()
    .setBlock('paragraph')
    .apply()
};